﻿<%@ Page Language="C#" MasterPageFile="~/Scores/MasterPage.master" AutoEventWireup="true" CodeFile="View.aspx.cs" Inherits="Scores_View" Title="无标题页" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   <script type="text/javascript">
        var template = '<span style="color:{0};">{1}</span>';

        var Shenhe = function (value) {
            if(value==0){return String.format(template,'blue', '未审核');}
            if(value==1){return String.format(template,'red', '有效');}
            if(value==2){return String.format(template,'green', '无效');}
        }
        var scoresformat = function(value){
        return value+'%';
        }
    </script>
    <ext:Store ID="StoreCompany" runat="server">
    <Reader>
        <ext:JsonReader ReaderID="companyid">
            <Fields>
                <ext:RecordField Name="companyid" Type="String"></ext:RecordField>
                <ext:RecordField Name="companyname" Type="String"></ext:RecordField>
                <ext:RecordField Name="companyaddress" Type="String"></ext:RecordField>
                <ext:RecordField Name="electricname" Type="String"></ext:RecordField>
                <ext:RecordField Name="tradename" Type="String"></ext:RecordField>
                <ext:RecordField Name="deptname" Type="String"></ext:RecordField>
                <ext:RecordField Name="credit" Type="String"></ext:RecordField>
                <ext:RecordField Name="scores" Type="Int"></ext:RecordField>
            </Fields>
        </ext:JsonReader>
    </Reader>
    
    </ext:Store>
    <ext:Store ID="StoreList" OnRefreshData="StoreList_onRefresh" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="guid">
                <Fields>
                    <ext:RecordField Name="username" Type="String"></ext:RecordField>
                    <ext:RecordField Name="deptname" Type="String"></ext:RecordField>
                    <ext:RecordField Name="status" Type="Int"></ext:RecordField>
                    <ext:RecordField Name="guid" Type="String"></ext:RecordField>
                    <ext:RecordField Name="companyid" Type="String"></ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter 
            Name="companyid" 
            Value="#{GridPanel1}.getSelectionModel().hasSelection() ? #{GridPanel1}.getSelectionModel().getSelected().id : -1"
            Mode="Raw">                    
            </ext:Parameter>
        </BaseParams>
    </ext:Store>
    <ext:Store ID="StoreDetail" OnRefreshData="StoreDetail_onRefresh" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="id">
                <Fields>
                    <ext:RecordField Name="id" Type="Int"></ext:RecordField>
                    <ext:RecordField Name="classname" Type="String"></ext:RecordField>
                    <ext:RecordField Name="tagname" Type="String"></ext:RecordField>
                    <ext:RecordField Name="detail" Type="String"></ext:RecordField>
                    <ext:RecordField Name="scores" Type="Int"></ext:RecordField>
                    <ext:RecordField Name="shidu" Type="String"></ext:RecordField>
                    <ext:RecordField Name="typename" Type="String"></ext:RecordField>
                    <ext:RecordField Name="basescores" Type="Int"></ext:RecordField>
                    <ext:RecordField Name="companyid" Type="String"></ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter 
            Name="guid" 
            Value="#{GridPanel3}.getSelectionModel().hasSelection() ? #{GridPanel3}.getSelectionModel().getSelected().id : -1"
            Mode="Raw">                    
            </ext:Parameter>
        </BaseParams>
    </ext:Store>
    <ext:ViewPort ID="ViewPort1" runat="server">
        <Body>
            <ext:RowLayout ID="RowLayout1" runat="server" Split="false">
                <ext:LayoutRow RowHeight="0.25">
                    <ext:GridPanel ID="GridPanel1" StoreID="StoreCompany" Title="客户列表" runat="server">
                    <ColumnModel>
                        <Columns>
                            <ext:Column ColumnID="companyid"  Header="户号" DataIndex="companyid" ></ext:Column>
                            <ext:Column ColumnID="companyname" Header="户名" DataIndex="companyname"></ext:Column>
                            <ext:Column ColumnID="tradename" Header="行业类别" DataIndex="tradename"></ext:Column>
                            <ext:Column ColumnID="electricname" Header="用电类别" DataIndex="electricname"></ext:Column>
                            <ext:Column ColumnID="scores" Header="信用分数" DataIndex="scores"></ext:Column>
                            <ext:Column ColumnID="credit" Header="信用等级" DataIndex="credit"></ext:Column>
                            
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                            <Listeners>
                                <RowSelect Handler="#{StoreList}.reload()" Buffer="250"  />
                            </Listeners>
                        </ext:RowSelectionModel>
                    </SelectionModel>
                   
                    </ext:GridPanel>
                </ext:LayoutRow>
                
                <ext:LayoutRow RowHeight="0.25">
                    <ext:GridPanel ID="GridPanel3" Title="客户评分记录列表" StoreID="StoreList" runat="server">
                        <ColumnModel>
                            <Columns>
                                <ext:Column ColumnID="username" DataIndex="username" Header="提交人"></ext:Column>
                                <ext:Column ColumnID="deptname" DataIndex="deptname" Header="提交人部门"></ext:Column>
                                <ext:Column ColumnID="status" DataIndex="status" Header="状态">
                                    <Renderer Fn="Shenhe" />
                                </ext:Column>
                                <ext:CommandColumn ColumnID="ok" Header="批准">
                                <Commands>
                                    <ext:GridCommand CommandName="allow" Icon="Accept" Text="通过"></ext:GridCommand>
                                    <ext:GridCommand CommandName="unallow" Icon="Disconnect" Text="退回">
                                    </ext:GridCommand>
                                </Commands>
                            </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
                                <Listeners>
                                    <RowSelect Handler="#{StoreDetail}.reload()" Buffer="250"  />
                                </Listeners>
                            </ext:RowSelectionModel>
                        </SelectionModel>
                           <AjaxEvents>
                                <Command OnEvent="Allow">
                                    <ExtraParams>
                                        <ext:Parameter Mode="Raw" Name="companyid" Value="record.data.companyid"></ext:Parameter>
                                        <ext:Parameter Mode="Raw" Name="guid" Value="record.data.guid"></ext:Parameter>
                                        <ext:Parameter Mode="Raw" Name="cmd" Value="command"></ext:Parameter>
                                    </ExtraParams>
                                </Command>
                            </AjaxEvents>
                    </ext:GridPanel>
                </ext:LayoutRow>
                
                <ext:LayoutRow RowHeight="0.5">
                     <ext:GridPanel ID="GridPanel2" Title="客户评分记录详细" StoreID="StoreDetail" runat="server">
                        <ColumnModel>
                            <Columns>
                                <ext:Column ColumnID="classname" DataIndex="classname" Header="要素"></ext:Column>
                                <ext:Column ColumnID="tagname" DataIndex="tagname" Header="指标"></ext:Column>
                                <ext:Column ColumnID="detail" DataIndex="detail" Header="指标说明"></ext:Column>
                                <ext:Column ColumnID="typename" DataIndex="typename" Header="指标类型"></ext:Column>
                                <ext:Column ColumnID="shidu" DataIndex="shidu" Header="适度区间"></ext:Column>
                                <ext:Column ColumnID="basescores" DataIndex="basescores" Header="权重">
                                <Renderer Fn="scoresformat" />
                                </ext:Column>
                                <ext:Column ColumnID="scores" DataIndex="scores" Header="得分"></ext:Column>
                            </Columns>
                        </ColumnModel>
                         
                    </ext:GridPanel>
                </ext:LayoutRow>
                
                
            </ext:RowLayout>
        </Body>
    </ext:ViewPort>
</asp:Content>

